import numpy as np
name = 'armadillo'
name = 'test'
def save_point_cloud_to_ply(points, filename):
    # 获取点的数量
    num_points = points.shape[0]
    # 写入PLY文件
    with open(filename, 'w') as f:
        f.write('ply\n')
        f.write('format ascii 1.0\n')
        f.write('element vertex %d\n' % num_points)
        f.write('property float x\n')
        f.write('property float y\n')
        f.write('property float z\n')
        f.write('end_header\n')
        for point in points:
            f.write(f'{point[0]} {point[1]} {point[2]}\n')
pc = np.loadtxt(name + '.xyz', dtype=np.float32)
save_point_cloud_to_ply(pc, name + '.ply')  # Save the point cloud to a PLY file